home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / play_speed / play_speed.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-03  |  1017 b   |  54 lines

  1. #include <stdio.h>
  2. #include <sys/types.h>
  3. #include <sys/stat.h>
  4. #include <fcntl.h>
  5. #include <errno.h>
  6. #ifdef _AUDIO_
  7. #include <sys/audio.h>
  8. #define DEV "/dev/audio"
  9. #define PLAY_IOCTL_SPEED AUDIO_SAMPLE_RATE
  10. #else
  11. #include <sys/sb.h>
  12. #define DEV "/dev/sbdsp"
  13. #define PLAY_IOCTL_SPEED DSP_IOCTL_SPEED
  14. #endif
  15.  
  16.  
  17. main ( count , args )
  18. char * args [] ;
  19. {
  20.     int speed ;
  21.     int device ;
  22.     int in ;
  23.     FILE * dev_stream ;
  24.     
  25.     if ( count != 2 )
  26.     {
  27.         fprintf ( stderr , "\nUsage: %s speed\n" , args [ 0 ] ) ;
  28.         return -1 ;
  29.     }
  30.     
  31.     speed = atoi ( args [ 1 ] ) ;
  32.  
  33.     device = open ( DEV , O_WRONLY ) ;
  34.     if ( device < 0 )
  35.     {
  36.         fprintf ( stderr , "\n%s: can't open %s for ioctl: %s\n" , args [ 0 ] , DEV , sys_errlist [ errno ] ) ;
  37.         return -1 ;
  38.     }
  39.     
  40.     if ( ioctl ( device , PLAY_IOCTL_SPEED , speed ))
  41.     {
  42.         fprintf ( stderr , "\n%s: can't ioctl: %s\n" , args [ 0 ] , sys_errlist [ errno ] ) ;
  43.         return -1 ;
  44.     }
  45.  
  46.     dev_stream = fdopen ( device , "a+" ) ;
  47.  
  48.     while (( in = getc ( stdin )) != EOF )
  49.     {
  50.         putc ( in , dev_stream ) ;
  51.     }
  52.     return 0 ;
  53. }
  54.